home *** CD-ROM | disk | FTP | other *** search
- /*
- ********************************************************************************
- **
- ** File: SimulEyes.c
- **
- ** Description:
- **
- ** This is a sample driver for GoggleSprocket, the stereoscopic device
- ** interface for the Macintosh. This driver will drive a pair of
- ** SimulEyes LCD glasses from StereoGraphics corporation.
- **
- ** © 1996 Apple Computer, Inc. All Rights Reserved.
- **
- ********************************************************************************
- */
- #include <Types.h>
- #include <Files.h>
-
- #include "GoggleSprocketDevices.h"
-
- #define kDialogID 128
- #define kItemOK 1
-
- /*
- ********************************************************************************
- ** globals
- ********************************************************************************
- */
- /* this device only supports a single "mode" */
- GSpDeviceModeInfo gModeInfo = {
- /* mode format is normal */
- kGSpModeDataFormat_Normal,
-
- /* special attributes */
- kGSpModeAttribute_CustomProcess | /* driver must process the images */
- kGSpModeAttribute_FullDisplayRequired | /* must be a full screen display */
- kGSpModeAttribute_PrimeBuffers, /* images must be preloaded into buffers before processing */
-
- /* display id (none required) */
- 0,
-
- /* display requirement ranges */
- { 0, 0 },
- { 0, 0 },
- { 0, 0 },
- { 0, 0 }
- };
-
- /*
- ********************************************************************************
- **
- ** Name: GSpDevice_Open
- **
- ** Description:
- **
- ** Called to allow the driver to do any setup.
- **
- ********************************************************************************
- */
- OSStatus /* result code */
- GSpDevice_Open( void )
- {
- return noErr;
- }
-
- /*
- ********************************************************************************
- **
- ** Name: GSpDevice_Close
- **
- ** Description:
- **
- ** Called to allow the driver to clean up.
- **
- ********************************************************************************
- */
- OSStatus /* result code */
- GSpDevice_Close( void )
- {
- return noErr;
- }
-
- /*
- ********************************************************************************
- **
- ** Name: GSpDevice_Configure
- **
- ** Description:
- **
- ** Called to tell the driver to display and manage its configuration dialog.
- **
- ********************************************************************************
- */
- OSStatus /* result code */
- GSpDevice_Configure(
- Point *inUpperLeft /* upper left corner of window, or NULL */
- )
- {
- DialogPtr theDialog;
- GrafPtr theSavePort;
-
- GetPort( &theSavePort );
-
- theDialog = GetNewDialog( kDialogID, NULL, (GrafPtr)-1 );
- if( theDialog )
- {
- short theItem = 0;
-
- SetDialogDefaultItem( theDialog, kItemOK );
-
- // if an upper left is provided, use it (parameter may be NULL)
- if( inUpperLeft )
- MoveWindow( theDialog, inUpperLeft->h, inUpperLeft->v, true );
- ShowWindow( theDialog );
-
- // show the dialog
- while( theItem != kItemOK )
- ModalDialog( nil, &theItem );
-
- // release the dialog memory
- DisposeDialog( theDialog );
- }
-
- SetPort( theSavePort );
-
- return noErr;
- }
-
- /*
- ********************************************************************************
- **
- ** Name: GSpDevice_GetFirstModeInfo
- **
- ** Description:
- **
- ** Return the first available mode the device supports.
- **
- ********************************************************************************
- */
- OSStatus /* result code */
- GSpDevice_GetFirstModeInfo(
- GSpDeviceModeInfo *outFirstModeInfo /* mode information (output) */
- )
- {
- *outFirstModeInfo = gModeInfo;
- return noErr;
- }
-
- /*
- ********************************************************************************
- **
- ** Name: GSpDevice_Open
- **
- ** Description:
- **
- ** The driver open call.
- **
- ********************************************************************************
- */
- OSStatus /* result code */
- GSpDevice_GetNextModeInfo(
- GSpDeviceModeInfo *inCurrentModeInfo,
- GSpDeviceModeInfo *outNextModeInfo
- )
- {
- return kGSpDeviceError_NoMoreModes;
- }
-
- /*
- ********************************************************************************
- **
- ** Name: GSpDevice_SetVisibleEye
- **
- ** Description:
- **
- ** Set the eye that can currently see the stereo image.
- **
- ********************************************************************************
- */
- OSStatus /* result code */
- GSpDevice_SetVisibleEye(
- Boolean inLeftEyeVisible /* TRUE = make left eye visible */
- )
- {
- return kGSpDeviceError_UnsupportedCall;
- }
-
- /*
- ********************************************************************************
- **
- ** Name: GSpDevice_GetVisibleEye
- **
- ** Description:
- **
- ** The driver open call.
- **
- ********************************************************************************
- */
- OSStatus /* result code */
- GSpDevice_GetVisibleEye(
- Boolean *outLeftEyeVisible /* TRUE = left eye is visible */
- )
- {
- return kGSpDeviceError_UnsupportedCall;
- }
-
- /*
- ********************************************************************************
- **
- ** Name: GSpDevice_CustomBufferProcess
- **
- ** Description:
- **
- ** The catch-all call that allows drivers with unique requirements to
- ** operate.
- **
- ** The SimulEyes glasses encode a signal in the last scan line of the
- ** image buffer by drawing a blue line followed by a black line. For
- ** the left eye, a blue line 1/4 the width of the buffer is drawn, followed
- ** by a 3/4 buffer-width black line. For the right eye, the blue line
- ** is 3/4 buffer-width, and the black line is 1/4 buffer width. This
- ** encoding MUST occur on the last scanline of the display, so simply
- ** placing them at the bottom of a window won't work.
- **
- ********************************************************************************
- */
- OSStatus GSpDevice_CustomBufferProcess(
- CGrafPtr inLeftEyeBuffer, /* left eye image */
- CGrafPtr inRightEyeBuffer, /* right eye image */
- CGrafPtr inDestBuffer, /* right eye image */
- Boolean inBuildLeftEyeBuffer, /* 0 = build right eye image */
- CTabHandle ioColorTable, /* src color table to use */
- Boolean *outShowDisplayBuffer, /* 0 = driver will show output */
- Boolean *outCTabChanged ) /* 0 = driver didnt change ctab */
- {
- GrafPtr theSavePort;
- UInt32 theWidth, theHeight;
-
- GetPort( &theSavePort );
-
- /* we're assuming the buffers are the same dimensions here */
- theWidth = inLeftEyeBuffer->portRect.right - inLeftEyeBuffer->portRect.left;
- theHeight = inLeftEyeBuffer->portRect.bottom - 1;
-
- /* encode the appropriate sync information */
- if( inBuildLeftEyeBuffer )
- {
- SetPort( (GrafPtr)inDestBuffer );
-
- /* blue line */
- ForeColor( blueColor );
- MoveTo( 0, theHeight );
- LineTo( theWidth/4, theHeight );
-
- /* black line */
- ForeColor( blackColor );
- MoveTo( theWidth/4, theHeight );
- LineTo( theWidth, theHeight );
- }
- else
- {
- SetPort( (GrafPtr)inDestBuffer );
-
- /* blue line */
- ForeColor( blueColor );
- MoveTo( 0, theHeight );
- LineTo( theWidth/4 * 3, theHeight );
-
- /* black line */
- ForeColor( blackColor );
- MoveTo( theWidth/4 * 3, theHeight );
- LineTo( theWidth, theHeight );
- }
-
- /* let the caller show the buffer */
- *outShowDisplayBuffer = true;
-
- /* we didn't change the color table */
- *outCTabChanged = false;
-
- /* restore the port */
- SetPort( theSavePort );
-
- return noErr;
- }
-
- /*
- ********************************************************************************
- **
- ** Name: GSpDevice_GetDeviceKind
- **
- ** Description:
- **
- ** Return the kind of device that this is.
- **
- ********************************************************************************
- */
- OSStatus /* result code */
- GSpDevice_GetDeviceKind(
- GSpDeviceKind *outDeviceKind
- )
- {
- *outDeviceKind = kGSpDeviceKind_FrameSequential;
- return noErr;
- }
-
-